import React, { Component } from 'react';
import {
    Platform,
    StyleSheet,
    Text,
    View,
    Dimensions,
    WebView

} from 'react-native';
import WkWebView               from 'react-native-wkwebview-reborn';
import BaseNavigationBar       from '../../views/BaseNavigationBar';
import * as BaseAPI            from "../../utils/BaseAPI";
const {width,height} = Dimensions.get('window');


export default class PlayGameScreen extends Component{

    popToBack(){
        this.props.navigation.goBack()
    }



    onNavigationStateChange(e) {

        console.log('打印1234'+ e);

        // if (e.url === HomeUrl){
        //
        // }else {
        //     this.goConfirmLogout();
        // }

        // if (e.url === LoginUrl){
        //     this.goConfirmLogout();
        // }
    }

    render() {

        var baseStr = '{"payIsTest":"0","servers":{"hall":"106.15.177.22:7510","http":"http:\\/\\/xy.xiaougame.com\\/","share":"","cdn":"http:\\/\\/192.168.6.203:8990\\/\\/client\\/"},"shortpkey":{"uid":29155,"un":"A72CF46B-8031-C070-C66D-751C50B95D2B@mobile","nn":"傻笑中的卅文豬","key":"bfed90b3e9ca652eb69fe5dafc7fa8e2|1|mobile|zh_CN"},"user":{"uid":29155,"pid":"","username":"A72CF46B-8031-C070-C66D-751C50B95D2B@mobile","tel":"","realname":"","reg_ip":"203.110.164.146","reg_date":1524484897,"gender":"f","nickname":"傻笑中的卅文豬","group_id":5,"locale":"zh_CN","upuid":0,"login_ip":"203.110.164.146","login_times":15,"login_days":2,"login_date":1524549578,"pay":"0.00","pay_num":0,"pay_value":"0.00","pay_date":0,"forbid_time":0,"remark":"","regcity":"上海","new_user":1,"appid":30,"logincity":"上海市","source":"","rtimes":3,"changes":0,"startdumb":0,"dumblimit":0,"state":0,"online":0,"online_times":0,"game_times":0,"ticket":0,"ticket_use":0,"pay_ticket":0,"golds":6000,"bonus_golds":0,"bank":0,"stones":0,"bonus_stones":0,"redpacket":"0.00","btimes":0,"bonus":"0.00","game_rounds":0,"game_wins":0,"rounds":0,"segment":0,"tcategory3":0,"tcategory4":0,"tcategory5":0,"liushui":0}}';

        return (
            <View style={styles.container}>

                <BaseNavigationBar
                    title={'Banner详情'}
                    leftImageSource={require('../../../images/other/ic_back.png')}
                    leftItemFunc={() => this.popToBack()}/>

                {/*<View style={{ flex:1}}>*/}
                    {/*<WkWebView style={{ backgroundColor: 'white',width:width }}*/}
                               {/*contentInsetAdjustmentBehavior="always"*/}
                               {/*userAgent="MyFancyWebView"*/}
                               {/*hideKeyboardAccessoryView={false}*/}
                               {/*ref={(c) => this.webview = c}*/}
                               {/*sendCookies={true}*/}
                               {/*onLoadEnd={(e) => console.log('onLoadEnd')}*/}
                               {/*onLoadStart={(e) => console.log('onLoadStart')}*/}
                               {/*onLoad={(e) => console.log('onLoad'+e)}*/}
                               {/*source={{ uri:BaseAPI.EnterPlayGameDataUrl+baseStr}}*/}
                               {/*onMessage={(e) => console.log(e.nativeEvent +'传参数')}*/}
                               {/*injectedJavaScript="window.postMessage('Hello from JavaScript'); document.addEventListener('message', e => { alert(e.data); });"*/}
                    {/*/>*/}
                    {/*/!*<Text style={{ fontWeight: 'bold', padding: 10 }} onPress={() => this.webview.reload()}>刷新</Text>*!/*/}
                    {/*/!*<Text style={{ fontWeight: 'bold', padding: 10 }} onPress={() => this.webview.postMessage("Hello from React Native")}>传递消息</Text>*!/*/}
                {/*</View>*/}

                <WebView
                ref={webView=>this.webView=webView}
                onNavigationStateChange={(e)=>this.onNavigationStateChange(e)}
                scalesPageToFit={false}
                automaticallyAdjustContentInsets={false}
                startInLoadingState={true}
                contentInset={{top:0,bottom:0}}
                scrollEnabled={true}
                onLoadEnd={(e) => console.log('onLoadEnd')}
                onLoadStart={(e) => console.log('onLoadStart')}
                onLoad={(e) => console.log('onLoad'+e)}
                renderError={() => {
                    console.log('renderError')
                    return <View><Text>renderError回调了，出现错误</Text></View>
                }}
                javaScriptEnabled={true}
                source={{url:'http://192.168.6.197:8901/bin/h5/index.html?p=xyhb&gid=10004&config={"payIsTest":"0","servers":{"hall":"106.15.177.22:7510","http":"http:\\/\\/xy.xiaougame.com\\/","share":"","cdn":"http:\\/\\/192.168.6.203:8990\\/\\/client\\/"},"shortpkey":{"uid":29155,"un":"A72CF46B-8031-C070-C66D-751C50B95D2B@mobile","nn":"傻笑中的卅文豬","key":"bfed90b3e9ca652eb69fe5dafc7fa8e2|1|mobile|zh_CN"},"user":{"uid":29155,"pid":"","username":"A72CF46B-8031-C070-C66D-751C50B95D2B@mobile","tel":"","realname":"","reg_ip":"203.110.164.146","reg_date":1524484897,"gender":"f","nickname":"傻笑中的卅文豬","group_id":5,"locale":"zh_CN","upuid":0,"login_ip":"203.110.164.146","login_times":15,"login_days":2,"login_date":1524549578,"pay":"0.00","pay_num":0,"pay_value":"0.00","pay_date":0,"forbid_time":0,"remark":"","regcity":"上海","new_user":1,"appid":30,"logincity":"上海市","source":"","rtimes":3,"changes":0,"startdumb":0,"dumblimit":0,"state":0,"online":0,"online_times":0,"game_times":0,"ticket":0,"ticket_use":0,"pay_ticket":0,"golds":6000,"bonus_golds":0,"bank":0,"stones":0,"bonus_stones":0,"redpacket":"0.00","btimes":0,"bonus":"0.00","game_rounds":0,"game_wins":0,"rounds":0,"segment":0,"tcategory3":0,"tcategory4":0,"tcategory5":0,"liushui":0}}'}}
                />

            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1
    }
});
